package com.igeek.clud_system.controller;



import com.igeek.clud_system.common.Const;
import jakarta.servlet.http.HttpSession;

import java.util.Random;

public class ValidateCode  {
    public void execute(HttpSession session) {
        //验证码的宽度
        int width=100;
        //验证码的高度
        int height=25;
        //验证码字符串
        String s="";
        //验证码出现范围的数组
        char[] code={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9'};

        //获取4位随机数
        Random random=new Random();
        for(int i=1;i<=4;i++){
            s+=code[random.nextInt(code.length)];
        }



        //保存验证码

        session.setAttribute(Const.CODE,s);


    }

}
